#define _CRT_SECURE_NO_WARNINGS 1
#include"stack.h"

void test() {
	ST st;
	STInit(&st);
	STPush(&st, 1);
	STPush(&st, 2);
	STPush(&st, 3);
	STPush(&st, 4);
	int num = STSize(&st);
	for (int i = 0; i < num; i++) {
		printf("%d ", st.a[i]);
	}
	printf("\n");
	STDestroy(&st);
}

bool isValid(char* s) {
	ST st;
	STInit(&st);
	while (*s) {
		if (((*s) == '(') || ((*s) == '[') || ((*s) == '{')) {
			STPush(&st, *s);
		}
		else {
			if (STEmpty(&st) == 1)
				return false;
			char top = STTop(&st);
			STPop(&st);
			if (top == '(' && *s == ')') {
			}
			else if (top == '[' && *s == ']') {
			}
			else if (top == '{' && *s == '}') {
			}
			else
				return false;
		}
		s++;
	}
	if (STEmpty(&st) == 0)
		return false;
	return true;
}

int main() {
	//test();
	char s[] = "]";
	bool ans = isValid(s);
	printf("%d\n", ans);
	return 0;
}